<%@ include file="header.jsp" %>

    <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
    <script type="text/javascript">
         var readOnly = ${readOnly};
    </script>
    <script type="text/javascript" src="js/voting.js"></script>
</head>
<body>

    <div class="content">
        <div class="defaultBlock">
            Someone said <a href="moanings/${moaning.id}" target="#">${moaning.text}</a>
        </div>
        <div class="defaultBlock">
            and someone else replied
            <ul id="replyList" class="defaultList">
                <c:forEach var="reply" items="${replies}">
                <li id="reply-${reply.id}">
                    <c:choose>
                        <c:when test="${readOnly}">
                            ${reply.text}
                        </c:when>
                        <c:otherwise>
                            [${reply.text}]
                        </c:otherwise>
                    </c:choose>
                </li>
                </c:forEach>
            </ul>
        </div>
        <div class="defaultBlock">
            <c:choose>
                <c:when test="${readOnly}">
                    Your choice was sent.
                </c:when>
                <c:otherwise>
                    <form:form commandName="vote">
                        <form:input type ="hidden" path="replyIds"  value="" id="userList" />
                        <form:input type ="hidden" path="moaningId" value="${moaning.id}"/>
                        <input type="submit" value="Send your choice"/>
                    </form:form>
                </c:otherwise>
            </c:choose>
        </div>
        <div class="defaultBlock">
            <a href="#" onClick="window.location.reload()">Try a different moaning</a>
        </div>
    </div>
</body>
</html>
